package com.syzsn.springcloud.controller;

import com.alibaba.fastjson.JSON;
import com.syzsn.springcloud.common.entity.Product;
import com.syzsn.springcloud.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ProductController {

    @Autowired
    private ProductService productService;

    @GetMapping("/product/{pid}")
    public Product product(@PathVariable("pid") Integer pid){
        Product product = productService.findByPid(pid);
        System.out.println("查询到商品：" + JSON.toJSONString(product));
        return product;
    }
}
